<?php

namespace app\admin\controller;

use QL\QueryList;// 使用插件
class Query
{
    public $like_not_need_login = [];
    public function index()
    {
        $html = 'https://chaoshi.detail.tmall.com/item.htm?id=557362791697&spm=875.7931836/B.2017039.3.7fd14265LW8p7e&scm=1007.12144.81309.73136_0_0&pvid=75d744a0-5398-4042-8342-b869cfadfa9f&utparam=%7B%22x_hestia_source%22:%2273136%22,%22x_object_type%22:%22item%22,%22x_hestia_subsource%22:%22default%22,%22x_mt%22:8,%22x_src%22:%2273136%22,%22x_pos%22:1,%22wh_pid%22:-1,%22x_pvid%22:%2275d744a0-5398-4042-8342-b869cfadfa9f%22,%22scm%22:%221007.12144.81309.73136_0_0%22,%22x_object_id%22:557362791697,%22tpp_buckets%22:%222144#0#81309#0%22%7D';// 手动获取页面

        $data = QueryList::html($html);// 得到页面内容
        $data->rules([     // 采集所有a标签的href属性
            'link' => ['#mainwrap #attributes a', 'href'],
            // 采集所有a标签的文本内容
//            'text' => ['a', 'text']
        ]);

// 此处$data = 上面已经获取到网页内容之后的对象
// 设置采集规则 替代了传统正则
        $data->query();
// 此处$data = 上面已经获取到网页内容之后的对象
// query 执行操作
        $data->getData();
// 此处$data = 上面已经获取到网页内容之后的对象

// 此处$data = 上面已经获取到网页内容之后的对象
        dump($data);
// 打印结果
    }
}